import wx

class MyFrame(wx.Frame):
    def __init__(self):
        # 创建窗体
        super().__init__(None, title = '单选按钮样例', size = (600, 800))
        panel = wx.Panel(self)
        str_list = ['男', '女', '中性']
        # rb = wx.RadioBox(panel, label = '性别', choices = str_list,
        #                  majorDimension = 3, style = wx.RA_SPECIFY_ROWS)
        self.rb = wx.RadioBox(panel, label='性别', choices = str_list)
        # self.Bind(wx.EVT_RADIOBOX, self.radio_change, self.rb)
        self.rb.Bind(wx.EVT_RADIOBOX, self.radio_change)

    def radio_change(self, event):
        print(f'选项切换，值的索引：{self.rb.GetSelection()}')
        print(f'选项切换，值：{self.rb.GetStringSelection()}')

app = wx.App()
window = MyFrame()
window.Show()
app.MainLoop()